import 'package:cbec_app/components/base/base_image.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

enum NotFoundType{
  ///收货地址
  address,
  ///商品
  goods,
  ///订单
  order
}

///缺省页组件
class NotFound extends StatelessWidget {
  ///自定义图片地址
  final String? url;

  ///描述文本
  final String? txt;

  ///类型
  final NotFoundType? notfoundType;

  const NotFound({super.key, this.url='', this.txt="暂无相关数据", this.notfoundType=NotFoundType.goods});

  @override
  Widget build(BuildContext context) {

    return Container(
      margin: EdgeInsets.only(top: 10.w),
      // height: 140.h,
      alignment: Alignment.center,
      child: Column(
        children: [
          url==''?BaseImage(url: getImagesUrl(notfoundType!), width: 140, height: 140):BaseImage(url: url!, width: 140, height: 140),
          Text(txt!,style: setTextStyle(14, FontWeight.w500, Tools.fromHex("#999999")))
        ],
      ),
    );
  }

  ///根据缺省类型获取图片地址
  String getImagesUrl(NotFoundType notFoundType){
    String imageUrl;
    switch(notFoundType){
      case NotFoundType.address:
          imageUrl = 'q_address.png';
      case NotFoundType.goods:
          imageUrl = 'q_goods.png';
      case NotFoundType.order:
        imageUrl = 'q_order.png';
      default:
        imageUrl = 'q_goods.png';
    }
    return imageUrl;
  }
}


